
using Midi::SequenceBuilder

const class Rest : MusicElement
{
  
  override const Float length

  new make( Num length:=1)
  {
    //echo ("***Note make $pitch $length $velocity ***")
    this.length = length.toFloat
  }

  internal new makeCopyOf (Rest n, |This f|? f := null) : this.make(n.length) {
    if (f != null) f(this)
  }

  virtual Rest copy(|This f|? f := null) {
    Rest.makeCopyOf(this,f)
  }

  virtual Str name() { "R" }

  @Operator
  override This mult(Num n) {
    copy{it.length=this.length*n.toFloat}
  }

  @Operator
  override This div(Num n) {
    copy{it.length=this.length/n.toFloat}
  }

  @Operator
  override Tune plus (MusicElement e) {
    Tune(this) + e
  }


  override Int size() { 1 }

  override Str toStr() {
    return name+(length==1f? "" : "*"+length)
  }
  
  virtual Str dump() {
    "Rest("+length+")"
  }
}